//
//  CAIExclusiveActionManager.m
//  MobileCaiLocal
//
//  Created by 海参 on 2022/10/13.
//  Copyright © 2022 com.Chs. All rights reserved.
//

#import "CAIExclusiveActionManager.h"

@interface CAIExclusiveActionManager ()

@property (nonatomic, assign) BOOL ignore;

@end


@implementation CAIExclusiveActionManager

- (void)exclusiveAction:(void(^)(void))block{
    [self exclusiveActionDelay:0.1 action:block];
}

- (void)exclusiveActionDelay:(NSTimeInterval)delay action:(void(^)(void))block{
    if (self.ignore) {
        return;
    }
    [self performSelector:@selector(resetState) withObject:nil afterDelay:delay];
    self.ignore = YES;
    if (block) {
        block();
    }
}


- (void)resetState{
    self.ignore = NO;
}

@end
